﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _02数组
{
    class LX2
    {
        static void Main(string[] args)
        {
            #region //声明方式一
            /*
            int size = 12;
            int[] mothArr = new int[size];
            //访问方式一
            //修改数组每一个元素
            for (int i = 0;i<mothArr.Length;i++)
            {
                mothArr[i] = i * 10;
                Console.WriteLine(mothArr[i]);
            }
            //访问方式二(只读遍历)
            foreach (int num in mothArr) 
            {
                //num *= 10;
                Console.WriteLine(num);
            }
            */
            #endregion
            #region //声明方式二
            /*
            int[] bymonthDayArr = new int[13]{0,31,28,31,30,31,30,31,31,30,31,30,31};
            foreach(var dayNum in bymonthDay)
            {
                Console.WriteLine(dayNum);
            }

            //Console.WriteLine("请输入年/月/日:"); 
            string str = "2020/3/5";
            char[] separtor = { '/' };
            string[] strArr = str.Split(separtor);
            int year = int.Parse(strArr[0]);//年
            int month = int.Parse(strArr[1]);//月
            int day = int.Parse(strArr[2]);//日
            int sum = 0;
            for (int i = 1;i < month;i++)
            {
                sum += bymonthDayArr[i];
            }
            sum += day; 
            //判断闰年
            if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
            {
                sum += 1;
                Console.WriteLine("是闰年");
            }
            Console.WriteLine("这是一年中的第{sum}天");
            */
            #endregion
            #region//二维数组
            //声明并初始化
            int[,] nineBoxArr = {{4,9,2},{3,5,7},{8,1,6}};
            Console.WriteLine(nineBoxArr[0,0] + nineBoxArr[0,1] + nineBoxArr[0,2]);
            for (int i = 0;i < 3;i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Console.Write(nineBoxArr[i,j] + "  ");
                }
                Console.WriteLine();
            }
            int[,,,,,,,,,,] worldArr = new int[2,2,2,2,2,2,2,2,2,2,2]; 
            #endregion
        }
    }
}